package com.example.wendao.model.service;

import androidx.paging.DataSource;

import com.example.wendao.model.db.dao.GoodsDao;
import com.example.wendao.model.db.database.AppDatabase;
import com.example.wendao.model.entity.Goods;

public class GoodsService {

    private GoodsDao goodsDao;

    public GoodsService(){
        goodsDao = AppDatabase.getDatabases().getGoodsDao();
    }

    public Goods findGoodById(int goodId){
        return goodsDao.findGoodById(goodId);
    }

    public DataSource.Factory<Integer, Goods> findAllGoods(){
        return goodsDao.findAllGoods();
    }

    public void deleteGoodById(int goodId){
        goodsDao.deleteGoodById(goodId);
    }

    public void deleteGood(Goods... good){
        goodsDao.deleteGood(good);
    }

    public void insertGoods(Goods... goods){
        goodsDao.insertGoods(goods);
    }

    public void updateGood(Goods goods){
        goodsDao.updateGood(goods);
    }

}
